package com.ruoyi.app.controller.checkrecord;

import com.ruoyi.app.business.check.CheckRecordBusiness;
import com.ruoyi.app.business.user.UserBusiness;
import com.ruoyi.app.company.CompanyBusiness;
import com.ruoyi.app.config.annotation.OperationAuth;
import com.ruoyi.app.domain.check.CheckRecord;
import com.ruoyi.app.domain.company.CompanyCheckResult;
import com.ruoyi.app.domain.company.CompanyInfo;
import com.ruoyi.app.domain.labor.LaborInfo;
import com.ruoyi.app.domain.user.UserCheckResult;
import com.ruoyi.common.core.utils.CommonUtils;
import com.ruoyi.common.core.web.domain.APIResult;
import com.ruoyi.common.core.web.page.CommonPageInfo;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.service.check.query.CheckRecordQuery;
import com.ruoyi.service.company.query.CompanyBaseQuery;
import com.ruoyi.service.user.enums.UserTypeEnum;
import com.ruoyi.service.user.query.LaborQuery;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 审核信息
 *
 * @author Zane
 * @since 2025-09-27
 */

@RestController
@OperationAuth(UserTypeEnum.PLATFORM_USER)
@RequestMapping("/checkRecord/")
public class CheckRecordController {

  @Resource
  private CheckRecordBusiness checkRecordBusiness;
  @Resource
  private UserBusiness userBusiness;
  @Resource
  private CompanyBusiness companyBusiness;

  /**
   * 已审核列表
   *
   */

  @PostMapping("list")
  public TableDataInfo<CheckRecord> list(@RequestBody CheckRecordQuery query) {
    final CommonPageInfo<CheckRecord> recordList = checkRecordBusiness.listRecord(query);
    return CommonUtils.buildTableData(recordList);
  }

  /**
   * 待审核项目方列表
   *
   */
  @PostMapping("companyNeedCheck")
  public TableDataInfo<CompanyInfo> listNeedCheck(@RequestBody CompanyBaseQuery query) {
    final CommonPageInfo<CompanyInfo> companyList = companyBusiness.listNeedCheck(
        query);
    return CommonUtils.buildTableData(companyList);
  }

  /**
   * 公司信息明细
   *
   */
  @PostMapping("companyCheckDetail")
  public APIResult<CompanyInfo> companyCheckDetail(@RequestParam("comId") Long comId) {
    CompanyInfo companyInfo = companyBusiness.companyCheckDetail(comId);
    return APIResult.success(companyInfo);
  }

  /**
   * 公司审核
   *
   */
  @PostMapping("checkCompany")
  public APIResult<Void> checkCompany(@RequestBody CompanyCheckResult checkResult) {
    userBusiness.checkCompany(checkResult);
    return APIResult.success();
  }

  /**
   * 待审核人员列表
   *
   */
  @PostMapping("laborNeedCheck")
  public TableDataInfo<LaborInfo> listNeedCheck(@RequestBody LaborQuery query) {
    final CommonPageInfo<LaborInfo> userList = userBusiness.listUserNeedCheck(query);
    return CommonUtils.buildTableData(userList);
  }

  /**
   * 审核人员
   *
   */
  @PostMapping("checkUser")
  public APIResult<Void> checkLabor(@RequestBody UserCheckResult checkResult) {
    userBusiness.checkLabor(checkResult);
    return APIResult.success();
  }

}
